const chartDom = echarts.init(document.getElementById('opinion'));

const initOpinion = opinionData => {
    chartDom.setOption({
        tooltip: {
            show: true,
            trigger: 'axis',
            formatter: '{b}</br> 数据为{c}',
            textStyle: {
                fontSize: '12'
            },
            backgroundColor: 'rgba(255,255,255,0.9)'
        },
        xAxis: {
            type: 'category',
            boundaryGap: true,

            axisTick: {
                show: true,
                alignWithLabel: true,
            },
            data: opinionData.map(i => i.x.substr(5, 5)),
            axisLine: {
                lineStyle: {
                    color: '#fff',
                    type: 'dashed'
                }
            },
            axisLabel: {
                // padding:[0,50,0,50]
                interval: 0,
                rotate: -40
            }
        },
        yAxis: {
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: '#fff',
                    // type: 'dashed'
                }
            },
            splitLine: {
                lineStyle: {
                    color: '#999',
                    type: 'dashed'
                }
            }
        },
        axisPointer: {
            lineStyle: {
                type: 'solid',
                color: '#000235'
            }
        },
        series: [{
            data: opinionData.map(i => i.y),
            type: 'line',
            areaStyle: {}
        }]
    });
}



$.ajax({
    type: 'post',
    url: url + '/api/data-visualization/store/opinion/trend',
    data: {
        beginDate: beginDate,
        endDate: endDate,
        keyword: '',
    },
    success(res) {
        if (res.code == 200) {
            console.log(res.data);
            initOpinion(res.data)
        }
    },
    error(err) {
        console.log(err);
    }
})